<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发票管理</title>
</head>
<body>
    <table class="table">
        <caption>用户及发票申请信息列表</caption>
        <thead>
        <tr>
            <th>序号</th>
            <th>申请人</th>
            <th>申请时间</th>
            <th>申请开票类型</th>
            <th>公司名称</th>
            <th>税号</th>
            <th>单位地址</th>
            <th>电话</th>
            <th>开户行</th>
            <th>银行账号</th>
            <th>邮箱</th>
            <th>邮寄联系人</th>
            <th>邮寄地址</th>
            <th>发票状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="i_content">

        </tbody>
    </table>
    <!--分页-->
    <div  style="text-align: center;margin-left: 40%;">
        <ul id="index_lm_cont_1_page"  style="margin: 0;"></ul>
    </div>





    <script>
        var searchdingdanfapiaolink = webrootpath+"dingdan/searchdingdanfapiaolink";
        var updatefpstatuslink = webrootpath+"dingdan/updatefpstatuslink";

        $(function () {
            searchdingdanfapiao(1);
        });

        function updatefapiaostatus(_dingdanid) {
            //更改订单状态 弹出框
            $("#index_fapiaozhuangtai_modal").modal("show");
            sessionStorage.setItem("dingdanid",_dingdanid)
        }
        function updatefpstatus() {
            var dingdanid = sessionStorage.getItem("dingdanid");
            var dingdanstatus = $("#fapiao_status_id").val();
            if(dingdanid!=null){
                $.get(updatefpstatuslink,{
                    dingdanid:dingdanid,
                    dingdanstatus:dingdanstatus
                },function (_info) {
                    if(_info.code=="1"){
                        $.alert(_info.msg);
                        $("#index_fapiaozhuangtai_modal").modal("hide");
                        searchdingdanfapiao(1);
                    }
                });
            }
        }
        /***
         * 获取订单信息列表
         */
        function searchdingdanfapiao(_pagenum) {
            $.post(searchdingdanfapiaolink,{
                pagenum:_pagenum
            },function (_info) {
                if(_info.code=="1"){
                    var datalist = _info.data;
                    var pages = _info.pages;

                    getworddatalist_pages(_pagenum,pages);
                    var htmlstr = "";
                    for(var i in datalist){
                        var dataobj = datalist[i];

                        var objtypetext = "";
                        if(dataobj.objtype==10){
                            objtypetext = "增值税普通发票";
                        }else if (dataobj.objtype==20){
                            objtypetext = "增值税专用发票";
                        }


                        var dingdanstatusstr = "";
                        if(dataobj.dingdanstatus=="10"){
                            dingdanstatusstr = "未开票";
                        }else if(dataobj.dingdanstatus=="20"){
                            dingdanstatusstr = "开票过程中";
                        }else if(dataobj.dingdanstatus=="30"){
                            dingdanstatusstr = "已开票";
                        }else if(dataobj.dingdanstatus=="40"){
                            dingdanstatusstr = "开票异常";
                        }


                        htmlstr +="<tr>" +
                                    "<td>"+i+"</td>" +
                                    "<td>"+dataobj.username+"</td>" +
                                    "<td>"+timestampToTime(dataobj.crdate)+"</td>" +
                                    "<td>"+objtypetext+"</td>" +
                                    "<td>"+dataobj.sGongsimingcheng+"</td>" +
                                    "<td>"+dataobj.sShuihao+"</td>" +
                                    "<td>"+dataobj.sDanweidizhi+"</td>" +
                                    "<td>"+dataobj.sDianhua+"</td>" +
                                    "<td>"+dataobj.sKaihuyinhang+"</td>" +
                                    "<td>"+dataobj.sYinhangzhanghao+"</td>" +
                                    "<td>"+dataobj.sYouxiang+"</td>" +
                                    "<td>"+dataobj.sExtend_1+"</td>" +
                                    "<td>"+dataobj.sExtend_2+"</td>" +
                                    "<td style='color: red;'>"+dingdanstatusstr+"</td>" +
                                    "<td><button class=\"btn btn-info\"   onclick='updatefapiaostatus(\""+dataobj.dingdanid+"\")' >更改发票状态</button></td>" +
                                "</tr>";
                    }
                    $("#i_content").html(htmlstr);

                }

            });
        }

        /***
         * 获取分类下词表内容_分页
         */
        function getworddatalist_pages(_pagenum,_pages){
            //处理分页
            $('#index_lm_cont_1_page').bootstrapPaginator({
                currentPage: _pagenum,
                totalPages: _pages,
                size:"normal",
                bootstrapMajorVersion: 3,
                alignment:"right",
                numberOfPages:5,
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                },
                onPageClicked: function (event, originalEvent, type, page) {
                    searchdingdanfapiao(page);
                }
            });
        }




    </script>

</body>
</html>